<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.w3.org/1999/xhtml" layout:decorator="layout">
<head th:include="layout :: htmlhead" th:with="title='favorites'"></head>
<body>
<scetion layout:fragment="content">
    <div class="fly-home" style="background-image: url();">
        <input type="hidden" th:value="${user.uid}" id="visitUid"/>
        <input type="hidden" th:value="${user.name}" id="visitUname"/>
        <input type="hidden" th:value="${user.avatar}" id="visitUavatar"/>
        <img src="" th:src="${user.avatar}" th:alt="${user.name}"/>
        <h1>
            <p th:text="${user.name}"></p>
            <i class="iconfont icon-nan"></i>
        </h1>
        <p class="fly-home-info">
            <!--<i class="iconfont icon-zuichun" title="飞吻"></i><span style="color: #FF7200;">67206飞吻</span>-->
           <i class="iconfont icon-shijian"></i><span th:text="${user.addtime}"></span>
           <!--<i class="iconfont icon-chengshi"></i><span>来自杭州</span>-->
            <i class="iconfont icon-qq" th:if="${user.self==false}"></i><a lay-event="addFriend" href="#" title="添加TA为好友" th:if="${user.self==false}">加为好友</a>
        </p>
        <p class="fly-home-sign" th:text="${user.sign}"></p>
    </div>

    <div class="main fly-home-main">
        <div class="layui-inline fly-home-jie">
            <div class="fly-panel">
                <h3 class="fly-panel-title">贤心 最近的提问</h3>
                <ul class="jie-row">
                    <li>
                        <span class="fly-jing">精</span>
                        <a href="/jie/{{item.id}}.html" class="jie-title">使用 layui 秒搭后台大布局（基本结构）</a>
                        <i>1天前</i>
                        <em>1136阅/27答</em>
                    </li>
                    <li>
                        <a href="/jie/{{item.id}}.html" class="jie-title">使用 layui 秒搭后台大布局（基本结构）</a>
                        <i>1天前</i>
                        <em>1136阅/27答</em>
                    </li>
                    <li>
                        <a href="/jie/{{item.id}}.html" class="jie-title">使用 layui 秒搭后台大布局（基本结构）</a>
                        <i>1天前</i>
                        <em>1136阅/27答</em>
                    </li>
                    <li>
                        <a href="/jie/{{item.id}}.html" class="jie-title">使用 layui 秒搭后台大布局（基本结构）</a>
                        <i>1天前</i>
                        <em>1136阅/27答</em>
                    </li>
                    <li>
                        <a href="/jie/{{item.id}}.html" class="jie-title">使用 layui 秒搭后台大布局（基本结构）</a>
                        <i>1天前</i>
                        <em>1136阅/27答</em>
                    </li>
                    <li>
                        <a href="/jie/{{item.id}}.html" class="jie-title">使用 layui 秒搭后台大布局（基本结构）</a>
                        <i>1天前</i>
                        <em>1136阅/27答</em>
                    </li>
                    <li>
                        <a href="/jie/{{item.id}}.html" class="jie-title">使用 layui 秒搭后台大布局（基本结构）</a>
                        <i>1天前</i>
                        <em>1136阅/27答</em>
                    </li>
                </ul>
                <!-- <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;"><i style="font-size:14px;">没有发表任何求解</i></div> -->
            </div>
        </div>

        <div class="layui-inline fly-home-da">
            <div class="fly-panel">
                <h3 class="fly-panel-title">贤心 最近的回答</h3>
                <ul class="home-jieda">
                    <li>
                        <p>
                            <span>1分钟前</span>
                            在<a href="" target="_blank">tips能同时渲染多个吗?</a>中回答：
                        </p>
                        <div class="home-dacontent">
                            尝试给layer.photos加上这个属性试试：
                            <pre>
full: true
</pre>
                            文档没有提及
                        </div>
                    </li>
                    <li>
                        <p>
                            <span>5分钟前</span>
                            在<a href="" target="_blank">在Fly社区用的是什么系统啊?</a>中回答：
                        </p>
                        <div class="home-dacontent">
                            Fly社区采用的是NodeJS。分享出来的只是前端模版
                        </div>
                    </li>
                </ul>
                <!-- <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;"><span>没有回答任何问题</span></div> -->
            </div>
        </div>

    </div>
    <script th:inline="javascript">
        layui.use(['layer','jquery','req','layim'],function (layer,$,req,layim) {
            var cacheGroup = null;
            events['addFriend'] = function () {
                getGroup(function (group) {
                    var user = {
                        username: $('#visitUname').val(),
                        avatar: $('#visitUavatar').val(),
                        group: group
                    }
                    layim.add({
                        type: 'friend'
                        , username: user.username
                        , avatar: user.avatar
                        , group: user.group
                        , submit: function (group, remark, index) {
                            apply({remark:remark,group:group}, function (res) {
                                if(res.code==0){
                                    layer.msg('好友申请已发送，请等待对方确认', {
                                        icon: 1
                                        , shade: 0.5
                                    }, function () {
                                        layer.close(index);
                                    });
                                }else{
                                    layer.msg(res.msg||"申请发送失败");
                                }
                            });

                        }
                    });
                })
            };
            var apply = function (param,callback) {
                var uid = $('#visitUid').val();
                req.loading = true;
                req.post('/layim/apply-friend',{toid:uid,remark:param.remark,group:param.group},function (res) {
                    callback(res);
                });
            }
            var getGroup = function (callback) {
                if(cacheGroup!=null){
                    callback(cacheGroup);
                }else {
                    req.loading = false;
                    req.get('/layim/friend-groups', {}, function (res) {
                        cacheGroup = res.data;
                        callback(res.data || []);
                    });
                }
            }
        })

    </script>
</scetion>
</body>

</html>